﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using OpenGL;

namespace Exhibition
{
	public class Carpet
	{
		public GLTexture T;
		public double Width, Height;

		public String FN;
		public Wall assignedwall;
		public bool BackSide;
		public double WallX;
		public int Legend;

		public String Text;

		public V3D CamPosition
		{
			get
			{
				return assignedwall.GetPosition(BackSide, WallX, 1.5) - CamTarget * 3;
			}
		}
		public V3D CamTarget
		{
			get
			{
				return -assignedwall.GetNormal(BackSide).Unit + V3D.Green * 0.2;
			}
		}

		public Carpet(String fn, double w, double h, Wall wall, bool bs, double wallx, int l, String txt)
		{
			T = new GLTexture(FN = fn);
			//T.Generate();
			Width = w;
			Height = h;
			assignedwall = wall;
			BackSide = bs;
			WallX = wallx;
			Legend = l;
			Text = txt;
		}
		public Carpet(Bitmap BMP, double w, double h, Wall wall, bool bs, double wallx, int l, String txt)
		{
			T = new GLTexture(BMP);
			Width = w;
			Height = h;
			assignedwall = wall;
			BackSide = bs;
			WallX = wallx;
			Legend = l;
			Text = txt;
		}

		public void Draw(bool selected)
		{
			if (selected)
				GL.glCol3D(V3D.Yellow);
			else
				GL.glCol3D(V3D.White);

			GL.glPushMatrix();
			assignedwall.GLTrans(BackSide, WallX);
			T.Draw(Width / 100, Height / 100, 1, 1);
			GL.glPopMatrix();
		}
	}
}